$(function () {
    setNewsTypeFindAll()
    setnewsFindId()
})

function setnewsFindId() {
    let da={
        id:localStorage.getItem("NewsId"),
    }
    let data=myAjax("/newsFindById",da,"get");
    data=data.newsModel;
    let html ='        <div class="newstitle">'+data.title+'</div>\n' +
            '        <div class="author">\n' +
            '            <div class="newsauthor">作者：'+data.author+'</div>\n' +
            '            <div class="newsauthor">日期：'+data.date+'</div>\n' +
            '            <div class="newsauthor">浏览次数:'+data.number+'</div>\n' +
            '        </div>\n' +
            '        <div class="content">'+data.content+'</div>\n' +
            '        <div class="detailed">'+data.detailed+'</div>';
    $("#news").html(html);
}

function setNewsTypeFindAll() {
    let data=myAjax("/News","","get");
    data=(data.NewsTypeFindAll);
    console.log(data);
    let html='<div>首页 >> 案例工程</div>';
    for (let i=0;i<data.length;i++){
        html +='<div class="product" onclick="setNewsType(\''+data[i].newstype+'\')"><p>'+data[i].newstype+'</p></div>';
    }
    $("#NewsType").html(html);
}

function setNewsType(newstype){
    localStorage.setItem("newstype",newstype);
    window.open("news.html","_self");
}